package com.wn.inventory.web;

import com.wn.common.PageBean;
import com.wn.common.ResponseEntity;
import com.wn.entity.ProductInWarehouseApplication;
import com.wn.inventory.service.ProductInWarehouseApplicationService;
import com.wn.inventory.vo.ProductInWarehouseApplicationVo;
import com.wn.validation_group.ProductInAddGroup;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * @ author     ：NST
 * @ date       ：Created in 2022/10/20 15:53
 * @ description：生产工单入库controller类
 * @ modified By：
 * @ version:
 */
@RequestMapping("inventory/product")
@RestController
public class ProductInWarehouseApplicationController {
    @Autowired
    ProductInWarehouseApplicationService productInWarehouseApplicationService;

    /**
     * @param product
     * @return com.wn.common.ResponseEntity
     * @ author nst
     * @ date 2022/10/20 16:14
     * @ Description 前台需要提供 申请人id,数量,工单号,流程id(测试，后续从其他模块调取)
     */
    @RequestMapping("add")
    public ResponseEntity add(@RequestBody @Validated({ProductInAddGroup.class}) ProductInWarehouseApplication product, HttpServletRequest request) {
        productInWarehouseApplicationService.insert(product,request);
        return ResponseEntity.success;
    }

    @RequestMapping("addition")
    public ResponseEntity getByCondition(@RequestBody ProductInWarehouseApplicationVo productInWarehouseApplicationVo){
        PageBean<ProductInWarehouseApplication> pageBean = productInWarehouseApplicationService.getByCondition(productInWarehouseApplicationVo);
        return new ResponseEntity(pageBean);
    }

}
